package ru.alt22.visor.php.ui.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;

public abstract class AbstractDelegatedAction extends Action implements IWorkbenchWindowActionDelegate {
	private IStructuredSelection selection;

	public AbstractDelegatedAction() {
		selection = null;
	}

	protected IStructuredSelection getSelection() {
		return selection;
	}
			
	public void setSelection(IStructuredSelection selection) {
		this.selection = selection;
	}

	public void run(IAction action) {
		run();
	}

	public void selectionChanged(IAction action, ISelection selection) {
		if (selection instanceof IStructuredSelection) {
			setSelection((IStructuredSelection) selection);
		}
	}

}
